﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace points.Assist
{
    public class Helper : System.Web.UI.Page
    {

        protected void CheckPageUsage(int customerType)
        {
            if (Session["CUSTOMER_PK"] != null)
            {
                int cPk = (int)Session["CUSTOMER_PK"];

                if (cPk < 0)
                {
                    RedirectHome();
                }
            }
            else
            {
                RedirectHome();
            }

            if (Session["CUSTOMER_TYPE_ID"] != null)
            {
                int cTypeID = (int)Session["CUSTOMER_TYPE_ID"];

                if (cTypeID < 0)
                {
                    RedirectHome();
                }
                else if (cTypeID != customerType)
                {
                    //if the session value isn't merchant...
                    RedirectHome();
                }
            }
            else
            {
                RedirectHome();
            }
        }

        protected void RedirectHome()
        {
            Response.Redirect("~/Login.aspx");
        }
    }
}